#ifndef __GAF_CFLASHACT_H__
#define __GAF_CFLASHACT_H__

#include "GAF_Define.h"

namespace GAF
{
	//struct ActionIntent;
		struct FlashIntent;
	//class Runnable
		//class Player
			//class Action
				class FlashAction;
}
typedef GAF::FlashIntent		GAF_SFlashIntent;
typedef GAF::FlashAction		GAF_CFlashAction;

#include "GAF_Action.h"

#define GAF_FA_TIMES_DEFAULT		0		// 无限次
#define GAF_FA_TIME_DEFAULT		1000

namespace GAF
{
	/// 闪烁动作目标效果结构
	struct FlashIntent : ActionIntent
	{
		/// 隐藏时间
		TimeTicks		ttHideTime;
		/// 显现时间
		TimeTicks		ttShowTime;
		/// 是否为渐显模式
		bool			isFadeIn;	// 是否渐显
		/// 是否为渐隐模式
		bool			isFadeOut;	// 是否渐隐
		/// 闪烁次数
		UINT			nTimes;

		FlashIntent()
		{
			ttHideTime	= GAF_FA_TIME_DEFAULT >> 1;
			ttShowTime	= GAF_FA_TIME_DEFAULT >> 1;
			isFadeIn	= false;
			isFadeOut	= false;
			nTimes		= GAF_FA_TIMES_DEFAULT;
		}
	};

	/// 闪烁动作类
	class FlashAction : public Action
	{
	public:
		FlashAction();
		~FlashAction();

		/// 设置闪烁效果
		void			SetIntent(ActionIntent* pIntent);
		/// 快捷方式，闪烁效果
		void			FlashFast(UINT nTimes = GAF_FA_TIMES_DEFAULT, TimeTicks ttTime = GAF_FA_TIME_DEFAULT, bool isFade = false);
		/// 快捷方式，闪烁效果
		void			Flash(UINT nTimes, TimeTicks ttHideTime, TimeTicks ttShowTime, bool isFade = false);

	protected:
		bool			Playing(Bundle* pbdlParam);
		bool			Running(TimeTicks ttUsed, bool& isFinish);
		bool			Stopping();

	private:
		bool			DoTimes();		// 记录次数，与判定是否结束
		void			ReadyShow();		// 准备显
		void			ReadyHide();		// 准备隐

	private:
		FlashIntent		m_Intent;
		UINT			m_nTimes;
		TimeTicks		m_ttLast;		// 上次时间
		bool			m_isHide;
		bool			m_isHostVisible;	// 记录宿主闪烁前的隐藏状态，闪烁结束后返回此状态
	};
}

#endif
